
package com.probiz.estore.exports.handler.product;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;

import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.product.ProductSku;
import com.probiz.estore.common.model.product.ProductSkuOptionValue;
import com.probiz.estore.exports.handler.ColumnHandler;
import com.probiz.estore.exports.model.Column;

public class SkuOptionHandler implements ColumnHandler{

	public String getProperty(Object target, Column column, HSSFSheet sheet, HSSFRow row, List<String> listHeader) {
		Product product = (Product)target;
		Set<ProductSku> set_sku = product.getProductSkus();
		Iterator<ProductSku> it = set_sku.iterator();
		StringBuffer psov_str = new StringBuffer("");;
		while(it.hasNext()){
			ProductSku sku = it.next();
			//规格选项
			Set<ProductSkuOptionValue> set_psov =  sku.getProductSkuOptionValues();
			Iterator<ProductSkuOptionValue> it_psov = set_psov.iterator();
			while(it_psov.hasNext()){
				ProductSkuOptionValue psov = it_psov.next();
				//尺码=XL;颜色=青
				psov_str.append(psov.getSkuOptionValue().getSkuOption().getSkuOptionName()).append("=").append(psov.getSkuOptionValue().getSkuOptionValueName()).append(";");
			}
		}
		return psov_str.toString();
	}

}
